using System;
using System.Collections.Generic;
using System.Text;
using LearningEnglishProgram.DTO;
using System.Data.SQLite;

namespace LearningEnglishProgram.DAO
{
    class WordsDAO : BaseDAO
    {
        public bool InsertWords( WordDTO wordDTO )
        {

            SQLiteCommand cmd = new SQLiteCommand(m_con);
            cmd.CommandText = Scripts.INSERT_WORDS(wordDTO);
            cmd.ExecuteNonQuery();

            base.closeConnection();

            return true;
        }

        static void Main()
        {
            //SQLiteConnection.CreateFile("Test.db");
            //SQLiteConnection con = new SQLiteConnection("Data Source=./Test.db;Version=3;");
            //con.Open();
            //con.ChangePassword("123456");
            //con.Close();

            //ILog log = Log.GetLog("Main");
            //log.Info("Create Database");

            WordsDAO dao = new WordsDAO();

            WordDTO wordDTO = new WordDTO();

            wordDTO.WORD = "Test";
            wordDTO.arrWordProperties = new List<WordPropertyDTO>();

            for (int nItem = 0; nItem < 10; nItem++)
            {
                WordPropertyDTO dto = new WordPropertyDTO();

                dto.ENGLISH_MEANING = "ENGLISH_MEANING" + nItem;
                dto.EXAMPLE = "EXAMPLE" + nItem;
                dto.PHONETIC = "PHONETIC" + nItem;
                dto.PREPOSITION = "PREPOSITION" + nItem;
                dto.PRONUNCIATION = "PRONUNCIATION" + nItem;
                dto.VIETNAMESE_MEANING = "VIETNAMESE_MEANING" + nItem;
                dto.WORD_FORM = "WORD_FORM" + nItem;

                wordDTO.arrWordProperties.Add(dto);
            }

            dao.InsertWords(wordDTO);
        }

    }
}
